﻿@{
    ViewBag.Title = "HSharp后台管理系统 - 登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment HostingEnvironment
@section header{
    <link href='@Url.Content("~/hsharp/css/login.css")' rel="stylesheet" />
    <script>
        if (window.top !== window.self) { window.top.location = window.location };
    </script>
    @BundlerHelper.Render(HostingEnvironment.ContentRootPath, Url.Content("~/lib/jquery.validation/1.14.0/jquery.validate.min.js"))
}
<div class="login-panel">
    <div class="row section"> 
            <form id="form">
            <h1 class="no-margin" style="font-weight: 600;font-size: 40px;">
                HSharpAdmin
            </h1>
                <p style="margin-top: 10px !important;">用户名/密码:推荐使用Gitee登录</p>
                <p>或加QQ群：972107977联系管理员</p>
                 <div class="row">
                    <div class="col-xs-12">
                            <input id="userName" name="userName" class="form-control uname" col="UserName" type="text" placeholder="用户名" value="@ViewBag.UserName" />
                    </div> 
                </div>
                <div class="row">
                    <div class="col-xs-12">
                         <input id="password" name="password" class="form-control pword m-b" col="Password" type="password" placeholder="密码" value="@ViewBag.Password" />
                    </div> 
                </div>
                
                @* <div class="row">
                    <div class="col-xs-6">
                        <input id="captchaCode" name="captchaCode" type="text" col="CaptchaCode" class="form-control code" placeholder="验证码" maxlength="3">
                    </div>
                    <div class="col-xs-6">
                        <a href="javascript:void(0);" title="点击更换验证码">
                            <img id="imgCaptchaCode" src='@Url.Content("~/Home/GetCaptchaImage")' height="34" />
                        </a>
                    </div>
                </div> *@
             
                <div class="row">
                    <div class="col-xs-12">
                           <div class="checkbox-custom">
                                <input id="rememberMe" name="rememberMe" type="checkbox"> <label for="rememberMe">记住我</label>
                            </div>
                    </div> 
                </div>
                <button class="btn btn-success btn-block" onclick="loginForm(); return false;">登录</button>
                <div style="text-align:center;border-top: solid 1px rgba(255, 255, 255, .3); margin-top: 10px;">
                    <p><h4>其他登录方式</h4></p>
                    <a href="@Url.Content("~/Oauth/Login")" target="_self">
                        <svg t="1671270284061" class="icon" style="background-color: #fff;border-radius:30px;margin-top:10px;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1920" width="30" height="30">
                            <path d="M512 1024C229.222 1024 0 794.778 0 512S229.222 0 512 0s512 229.222 512 512-229.222 512-512 512z m259.149-568.883h-290.74a25.293 25.293 0 0 0-25.292 25.293l-0.026 63.206c0 13.952 11.315 25.293 25.267 25.293h177.024c13.978 0 25.293 11.315 25.293 25.267v12.646a75.853 75.853 0 0 1-75.853 75.853h-240.23a25.293 25.293 0 0 1-25.267-25.293V417.203a75.853 75.853 0 0 1 75.827-75.853h353.946a25.293 25.293 0 0 0 25.267-25.292l0.077-63.207a25.293 25.293 0 0 0-25.268-25.293H417.152a189.62 189.62 0 0 0-189.62 189.645V771.15c0 13.977 11.316 25.293 25.294 25.293h372.94a170.65 170.65 0 0 0 170.65-170.65V480.384a25.293 25.293 0 0 0-25.293-25.267z" fill="#C71D23" p-id="1921"></path>
                        </svg>
                    </a>
                    <a href="@Url.Content("~/Oauth/GitCodeLogin")" target="_self">
                        <svg t="1730797916712" class="icon" style="background-color: #fff;border-radius:30px;margin-top:10px;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4285" width="30" height="30">
                            <path d="M517.176889 28.444444c124.359111 0 240.184889 46.449778 328.931555 122.965334 2.190222 2.56 4.124444 5.048889 5.632 7.409778 55.025778 127.232-75.064889 181.276444-130.104888 145.052444-55.04-36.224-15.416889-91.363556-42.737778-101.134222-44.657778 2.645333-80.554667 47.829333-145.422222 53.802666-13.482667 0-47.886222-6.570667-79.217778-4.764444-30.862222 1.777778-59.633778 10.695111-70.926222 10.695111-68.935111-4.352-94.208-36.622222-105.856-26.652444-3.541333 16.568889 3.626667 80.170667-1.678223 107.548444-5.319111 27.377778-54.727111 93.795556-65.792 162.759111-11.050667 68.977778-6.385778 113.891556 7.338667 149.319111 13.724444 35.413333 81.692444 165.091556 316.131556 165.091556 242.602667-2.275556 312.604444-135.253333 312.604444-179.100445 0-43.861333-24.277333-56.817778-141.525333-64.426666-117.248-7.594667-186.595556-3.811556-192.810667-47.672889-6.215111-43.861333 15.872-76.586667 55.822222-82.958222 39.964444-6.371556 177.464889-8.675556 227.982222-4.337778 50.161778 4.309333 223.288889 54.186667 198.570667 218.424889-64.241778 196.821333-257.265778 334.563556-476.942222 334.563555C247.253333 995.029333 28.444444 787.086222 28.444444 517.162667 28.444444 247.267556 247.253333 28.444444 517.176889 28.444444z" fill="#d81e06" p-id="4286">
                            </path>
                        </svg>
                    </a>
                <a href="https://gitee.com/ldhnet/HSharpAdmin" style="padding:5px; float: right;width:120px;color:#fff; font-size: 14px;font-weight: 700;background-color: red;border-radius:30px;margin-top:10px;" target="_blank"> Gitee去Star </a>
                </div>
                
            </form> 
    </div>
    <div class="login-footer">
        @*<div style="text-align:center">
            &copy; 2018-@DateTime.Now.Year <a href="#" target="_blank" style="color:white"></a> All Rights Reserved.<br>
            <a href="http://www.beian.miit.gov.cn/" target="_blank" rel="nofollow"></a><br>
        </div>*@
    </div>
</div>
<script type="text/javascript">
    $(function () {
        if ($.cookie('RememberMe') == 1) {
            $("#rememberMe").prop("checked", true);
            if ("@GlobalContext.SystemConfig.LoginProvider" == "Cookie") {
                if (!ys.isNullOrEmpty($.cookie('UserToken'))) {
                    redirectToIndex();
                }
            }
            else {
                $.removeCookie("UserToken", { path: '/' });
            }
        }
  

        // $("#imgCaptchaCode").click(function () {
        //     $(this).attr("src", '@Url.Content("~/Home/GetCaptchaImage")' + '?t=' + new Date().getTime());
        // });
        $("#goStar").click(function () {
            if ($(this).prop("checked")) {
                $.cookie('RememberMe', 1, { expires: 30, path: '/' });
            }
        });
        

        $("#form").validate({
            rules: {
                userName: { required: true },
                password: { required: true }
            }
        });

        $.validator.setDefaults({
            submitHandler: function () {
                loginForm();
            }
        });
    });

    function loginForm() {
        if ($("#form").validate().form()) {
            var postData = $("#form").getWebControls();
            ys.ajax({
                url: '@Url.Content("~/Home/LoginJson")',
                type: "post",
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        redirectToIndex();
                    } 
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }  
    function redirectToIndex() {
        location.href = '@Url.Content("~/Home/Index")';
    }
</script>